package com.design.demo.decorator;

import java.io.FileNotFoundException;

/**
 * @author guoliang.li
 * @date 2019/12/26 12:58
 * @description TODO jdk io就是通过装饰器模式实现的。
 */
public class Client {
    public static void main(String[] args) throws FileNotFoundException {
        BaseComponent espressoComponent = new EspressoComponent();
        System.out.println(espressoComponent.getDescription() + "\t" + espressoComponent.cost());
        System.out.println("=================");

        BaseComponent houseBlendComponent = new HouseBlendComponent();
        System.out.println(houseBlendComponent.getDescription() + "\t" + houseBlendComponent.cost());
        System.out.println("===================");

        BaseComponent darkRoastComponent = new DarkRoastComponent();
        System.out.println(darkRoastComponent.getDescription() + "\t" + darkRoastComponent.cost());
        System.out.println("====================");

        BaseDecorator decorator = new MochaWrapper(espressoComponent);
        System.out.println(decorator.getDescription() + "\t" + decorator.cost());
        System.out.println("======================");

        BaseDecorator decorator1 = new MochaWrapper(houseBlendComponent);
        System.out.println(decorator1.getDescription() + "\t" + decorator1.cost());
        System.out.println("=======================");

        BaseDecorator decorator2 = new MochaWrapper(darkRoastComponent);
        System.out.println(decorator2.getDescription() + "\t" + decorator2.cost());
        System.out.println("======================");


        houseBlendComponent = new MochaWrapper(espressoComponent);
        darkRoastComponent = new MochaWrapper(houseBlendComponent);
        espressoComponent = new WhipWrapper(darkRoastComponent);

        System.out.println(espressoComponent.getDescription() + "\t" + espressoComponent.cost());
        System.out.println("======================");

        BaseDecorator decorator3 = new MochaWrapper(new MochaWrapper(new MochaWrapper(new MochaWrapper(new WhipWrapper(new EspressoComponent())))));
        System.out.println(decorator3.getDescription() + "\t" + decorator3.cost());
    }
}